package com.sky.config;

import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * @author iTaotao
 * @version 1.0.0
 * @ClassName RedisConfiguration.java
 * @Description Redis数据库配置类
 * @createTime 2023年07月31日 10:47:00
 */
@Configuration
public class RedisConfiguration {
    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
        RedisTemplate<Object , Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        redisTemplate.setKeySerializer((new StringRedisSerializer()));
        redisTemplate.setDefaultSerializer((new GenericFastJsonRedisSerializer()));
        return redisTemplate;

    }
}
